package models

import (
	orm "go-admin/common/global"
	"time"
)

/**
* @Description:
* @Author: yuweizhu
* @Date: 2020/11/22 10:26 下午
**/
type TRightsPermConfig struct {
	ID          int `json:"id"`
	Type        int `json:"type"`
	LinkCount   int
	ClickCount  int
	Api         int
	Jingwai     int
	Amount      int
	CreatedTime *time.Time `json:"createdTime"`
}

func (TRightsPermConfig) TableName() string {
	return "t_rights_perm_config"
}

func (e *TRightsPermConfig) Get() (config *TRightsPermConfig, err error) {

	table := orm.GetDb().Table(e.TableName()).Select([]string{"t_rights_perm_config.*"})
	if e.ID != 0 {
		table = table.Where("id = ?", e.ID)
	}

	var res TRightsPermConfig
	if err = table.Where(e).First(&res).Error; err != nil {
		return
	}
	config = &res
	return
}

